//
//  ViewController.m
//  UI16_UICollectionViewCycleImage
//
//  Created by Hanlingyu on 16/8/4.
//  Copyright © 2016年 ltq. All rights reserved.
//

#import "ViewController.h"
#import "LtqCycleImages.h"
//@class LtqCycleImagesCell;
@interface ViewController ()
<
    LtqCycleImagesCellClickedDelegate,
    ltqCycleImagesDataSource
>
@property (weak, nonatomic) IBOutlet LtqCycleImages *cycleImage;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
//    LtqCycleImages *cycleImage = [[LtqCycleImages alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 200)];
//    [self.view addSubview:cycleImage];
    
    
    NSMutableArray *array = [NSMutableArray array];
    for (int i = 0; i < 5; i++) {
        [array addObject:[NSString stringWithFormat:@"%d.jpg", i]];
    }
    NSString *firstImage = [array firstObject];
    NSString *lastImage = [array lastObject];
    [array insertObject:lastImage atIndex:0];
    [array addObject:firstImage];
    
    _cycleImage.array = array;
    
    _cycleImage.delegate = self;

    _cycleImage.dataSource = self;
    
}

//- (void)handleDataWithObject:(id)objc cell:(__kindof UICollectionViewCell *)cell {
//    
//    NSString *imageName = objc;
//    LtqCycleImagesCell *imageCell = cell;
//    imageCell.cycleImage.image = [UIImage imageNamed:imageName];
//    
//    
//    
//}

// 这个方法也在重用池中, 所以不要在这个方法中添加控件
- (void)handleDataWithObject:(NSString *)objc cell:(LtqCycleImagesCell *)cell {
    cell.cycleImage.image = [UIImage imageNamed:objc];
}

- (void)cellClicked:(NSIndexPath *)indexPath {
    
    NSLog(@"我点击了第%ld个ldcell", indexPath.row);
    
    
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
